<template>
  <nav class="navbar" :class="{ 'navbar-scrolled': isScrolled }">
    <div class="container">
      <div class="navbar-content">
        <div class="logo">
          <router-link to="/" class="logo-text">
            广州迷失之牙商贸有限责任公司
            <span class="logo-subtitle">出色的跨境电商商贸公司</span>
          </router-link>
        </div>
        <div class="nav-links" :class="{ 'active': isMenuOpen }">
          <router-link to="/" class="nav-link">首页</router-link>
          <router-link to="/about" class="nav-link">关于我们</router-link>
          <router-link to="/services" class="nav-link">业务范围</router-link>
          <router-link to="/team" class="nav-link">团队介绍</router-link>
          <router-link to="/contact" class="nav-link">联系我们</router-link>
        </div>
        <div class="menu-toggle" @click="toggleMenu">
          <span class="menu-icon"></span>
        </div>
      </div>
    </div>
  </nav>
</template>

<script setup>
import { ref, onMounted, onUnmounted } from 'vue'

const isScrolled = ref(false)
const isMenuOpen = ref(false)

const handleScroll = () => {
  isScrolled.value = window.scrollY > 50
}

const toggleMenu = () => {
  isMenuOpen.value = !isMenuOpen.value
}

onMounted(() => {
  window.addEventListener('scroll', handleScroll)
})

onUnmounted(() => {
  window.removeEventListener('scroll', handleScroll)
})
</script>

<style scoped>
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: transparent;
  transition: all 0.3s ease;
  padding: 20px 0;
}

.navbar-scrolled {
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  padding: 15px 0;
}

.navbar-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  z-index: 1001;
}

.logo-text {
  text-decoration: none;
  font-size: 24px;
  font-weight: bold;
  color: #fff;
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.navbar-scrolled .logo-text {
  color: #333;
}

.logo-subtitle {
  font-size: 12px;
  font-weight: normal;
  color: #3498db;
  margin-top: 5px;
}

.nav-links {
  display: flex;
  gap: 30px;
}

.nav-link {
  color: #fff;
  text-decoration: none;
  font-weight: 500;
  transition: all 0.3s ease;
  position: relative;
}

.navbar-scrolled .nav-link {
  color: #333;
}

.nav-link:hover {
  color: #3498db;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 0;
  width: 0;
  height: 2px;
  background: #3498db;
  transition: width 0.3s ease;
}

.nav-link:hover::after {
  width: 100%;
}

.menu-toggle {
  display: none;
  cursor: pointer;
}

.menu-icon {
  display: block;
  width: 30px;
  height: 2px;
  background: #fff;
  position: relative;
}

.navbar-scrolled .menu-icon {
  background: #333;
}

.menu-icon::before,
.menu-icon::after {
  content: '';
  position: absolute;
  width: 30px;
  height: 2px;
  background: inherit;
  transition: all 0.3s ease;
}

.menu-icon::before {
  top: -8px;
}

.menu-icon::after {
  bottom: -8px;
}

@media (max-width: 768px) {
  .menu-toggle {
    display: block;
    z-index: 1001;
  }

  .nav-links {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transform: translateX(100%);
    transition: transform 0.3s ease;
  }

  .nav-links.active {
    transform: translateX(0);
  }

  .nav-link {
    font-size: 1.5rem;
    margin: 15px 0;
  }
}
</style> 